<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ page import="java.util.Date"%>
<%@ include file="../security/include.inc.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>会员查询</title>
</head>
<body>
    <div class="mini-fit">
    	<fieldset id="fd_data" class="hideFieldset" style="width:85%;margin: 10px;">
	        <legend><label><input type="checkbox"  id="checkbox1" onclick="toggleFieldSet(this, 'fd_data')" />批量会员导入</label></legend>
	        <div class="fieldset-body">
	        	<input id="fileupload1" class="mini-fileupload" name="Fdata" limitType="*.xls" flashUrl="<%=swfPath %>" uploadUrl="<%=basePath %>/member/batchSave" 
                        	onuploadsuccess="onUploadSuccess" onuploaderror="onUploadError" onfileselect="onFileSelect" />
                <a class="mini-button" iconCls="icon-upload" onclick="startUpload()" >EXCEL上传</a>
	        </div>
	    </fieldset> 
    	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                    </td>
                </tr>
            </table>           
        </div>
	    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:90%;"  fitColumns="false" showPager="false" 
		url="<%=basePath%>/member/managerList">
			<div property="columns">
				<div type="indexcolumn"></div>
				<div field="member_id" width="100" headerAlign="center" vtype="required">会员编号
				</div>
				<div field="name" width="100" headerAlign="center">会员名称
				</div>
				<div field="level" width="100" headerAlign="center">会员级别
				</div>
				<div field="register_date" width="100" headerAlign="center" dateFormat="yyyy-MM-dd">创建时间
				</div>
				<div field="channel_id" width="100" headerAlign="center">加盟商编号
				</div>
				<div field="o_cust" width="100" headerAlign="center">原客户编号
				</div>
				<div field="cr_fee" width="100" headerAlign="center">已交会费金额
				</div>
			</div>
			
		</div>
    </div>
	
	<script type="text/javascript">
	 	mini.parse();
		var grid = mini.get("datagrid1");
	    grid.load();
	    
		//////////////////////////////////////////////////////
		
		
		function search() {       
            var obj = {};
            if("" != mini.get("cbl1").getValue()){
            	obj.yearSection = mini.get("cbl1").getValue();
            }
            var locationSection = mini.get("cbl2").getValue();
            if("" != locationSection && locationSection.indexOf("100000") < 0){
            	obj.locationSection = mini.get("cbl2").getValue();
            }
            var json = mini.encode(obj);
            grid.load({ key: json });
        }
        
        function reset(){
        	mini.get("cbl1").setValue();
        	mini.get("cbl2").setValue();
        }
        
        function addRow() {          
            var newRow = { name: "New Row"};
            grid.addRow(newRow, 0);
        }
        function removeRow() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                grid.removeRows(rows, true);
            }
        }
        function saveData() {
            var data = grid.getChanges();
            
            if(data.length == 0) return;
            
            
            var json = mini.encode(data);
            
            console.log(data);
            
             grid.loading("保存中，请稍后......");
             $.ajax({
                url: "<%=basePath%>/channelInfo/save",
                 data: { data: json },
                 type: "post",
                 success: function (text) {
                	 alert(text);
                     grid.reload();
                 },
                 error: function (jqXHR, textStatus, errorThrown) {
                     alert(jqXHR.responseText);
                 }
             });
        }
        function toggleFieldSet(ck, id) {
            var dom = document.getElementById(id);
            dom.className = !ck.checked ? "hideFieldset" : "";
        }
        
        function onUploadSuccess(e) {

            alert(e.serverData);
        }
        function onUploadError(e) {
        	alert('文件上传异常');
            
        }

        function startUpload() {
			var fileupload = mini.get("fileupload1");
       		fileupload.startUpload();
        }
        
	</script>
</body>
</html>